<?php

namespace App\Traits;

use App\Services\Api\Api;
trait IndustryTrait
{

    /**
     * 解决方案列表
     * @param  [type] $request            [description]
     * @param  string $otherConfig        [description]
     * @param  [type] $currentTabMenuList [description]
     * @param  [type] $apiCode            [description]
     * @return [type]                     [description]
     */
    public function getFilterIndustrySolutionCoo($request, $otherConfig = '', $currentTabMenuList, $apiCode)
    {
        $type = $request->input('type');
        if (!isset($currentTabMenuList[$type])) {
            $type = 1;
        }
        $type = isset($otherConfig['type']) ? $otherConfig['type'] : $type;
        $domainId = $currentTabMenuList[$type]['java_flag_type'];
        $formData = [
            'pageNo' => $request->input('page', 1),
            'pageSize' => $request->input('limit', isset($otherConfig['limit']) ? $otherConfig['limit'] : 2),
            'title' => $request->input('title', ''),
            'techRoute' => $request->input('tech_checkbox', -1),
            'domainId' => $domainId,
            'typeId' => 1,
        ];

        $obj = new Api();
        $postData = $obj->getJavaPostData($apiCode, $formData);
        $result = $obj->getJavaResponseData($postData);
        if ($result) {
            return [
                'dataList' => $result['dataList'],
                'pageCount' => $result['pageTotal'],
                'filterType' => $type,
            ];
        }
        return false;
    }

    /**
     * 绿色成果
     * @param  [type]
     * @param  [type]
     * @return [type]
     */
    public function getFilterIndustryGreenResultCoo($request, $apiCode)
    {
        $formData = [
            'pageNo' => $request->input('page', 1),
            'pageSize' => $request->input('limit', 5),
            'title' => $request->input('title', ''),
        ];
        $obj = new Api();
        $postData = $obj->getJavaPostData($apiCode, $formData);
        $result = $obj->getJavaResponseData($postData);
        if ($result) {
            return [
                'dataList' => $result['dataList'],
                'pageCount' => $result['pageTotal'],
            ];
        }
        return false;
    }
}
